package la.iok.hzsvn.lewin.movie.entity;

import la.iok.hzsvn.share.collection.IdAble;

import java.time.LocalDate;
import java.util.Objects;

public class HolidayConfig implements IdAble<Long> {
    private Long id;
    /**
     * 日期
     */
    private LocalDate date;
    /**
     * 假期类型。0：工作日，1：假期
     */
    private Integer type;

    @Override
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public LocalDate getDate() {
        return date;
    }

    public void setDate(LocalDate date) {
        this.date = date;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    /**
     * 判断是否假期
     * @return 是假期返回true,否则false
     */
    public boolean holiday(){
        return type != null && type == 1;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof HolidayConfig)) return false;
        HolidayConfig config = (HolidayConfig) o;
        return Objects.equals(id, config.id) && Objects.equals(date, config.date) && Objects.equals(type, config.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, date, type);
    }

    @Override
    public String toString() {
        return "HolidayConfig{" +
                "id=" + id +
                ", date=" + date +
                ", type=" + type +
                '}';
    }
}
